home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / dns / inet.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  1KB  |  64 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import socket
  5. import dns.ipv4 as dns
  6. import dns.ipv6 as dns
  7. AF_INET = socket.AF_INET
  8.  
  9. try:
  10.     AF_INET6 = socket.AF_INET6
  11. except AttributeError:
  12.     AF_INET6 = 9999
  13.  
  14.  
  15. def inet_pton(family, text):
  16.     if family == AF_INET:
  17.         return dns.ipv4.inet_aton(text)
  18.     elif family == AF_INET6:
  19.         return dns.ipv6.inet_aton(text)
  20.     else:
  21.         raise NotImplementedError
  22.  
  23.  
  24. def inet_ntop(family, address):
  25.     if family == AF_INET:
  26.         return dns.ipv4.inet_ntoa(address)
  27.     elif family == AF_INET6:
  28.         return dns.ipv6.inet_ntoa(address)
  29.     else:
  30.         raise NotImplementedError
  31.  
  32.  
  33. def af_for_address(text):
  34.     
  35.     try:
  36.         junk = dns.ipv4.inet_aton(text)
  37.         return AF_INET
  38.     except:
  39.         
  40.         try:
  41.             junk = dns.ipv6.inet_aton(text)
  42.             return AF_INET6
  43.         raise ValueError
  44.  
  45.  
  46.  
  47.  
  48. def is_multicast(text):
  49.     
  50.     try:
  51.         first = ord(dns.ipv4.inet_aton(text)[0])
  52.         if first >= 224:
  53.             pass
  54.         return first <= 239
  55.     except:
  56.         
  57.         try:
  58.             first = ord(dns.ipv6.inet_aton(text)[0])
  59.             return first == 255
  60.         raise ValueError
  61.  
  62.  
  63.  
  64.